import { uniRequset } from '@/utils/request'
import type { postCart } from '@/types/cart'
import type { cartListType } from '@/types/cart'
export const addCartApi = (data: postCart) => {
  return uniRequset({
    url: '/cart/add_cart/',
    method: 'POST',
    data,
  })
}

export const getCartListApi = () => {
  return uniRequset<cartListType[]>({
    url: '/cart/get_cart_list/',
    method: 'GET',
  })
}

export const deleteCartApi = (cart_id: number) => {
  return uniRequset({
    url: `/cart/delete_cart/${cart_id}/`,
    method: 'DELETE',
  })
}

export const updateCartApi = (cart_id: number, num: number) => {
  return uniRequset({
    url: `/cart/update_cart/${cart_id}/`,
    method: 'PUT',
    data: { num },
  })
}
